package com.bitinstitute.parkapp;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.bitinstitute.parkapp.help.HelpActivity;
import com.bitinstitute.parkapp.helper.TabGroupActivity;
import com.bitinstitute.parkapp.quiz.QuizActivity;
import com.bitinstitute.parkapp.wallpaper.WallpaperActivity;

public class MoreActivityList extends Activity {

	private ListView lv1;

	// List of clickable items
	private String lv_arr[] = { "Teilen", "QR-Code scannen", "Quiz", "Wallpaper", "Hilfe"};

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more_layout);

		lv1 = (ListView) findViewById(R.id.listViewMore);

		lv1.setAdapter(new ArrayAdapter<String>(this, R.layout.custom_list_item, android.R.id.text1, lv_arr));

		lv1.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {

				switch (position) {
				case 0:
					// Creates Intent for sending-request
					Intent shareIntent = new Intent(
							android.content.Intent.ACTION_SEND);
					// define Type
					shareIntent.setType("text/plain");
					// Subject
					shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
							"Betreff: Interactive Park App");
					// Message
					String shareMessage = "Ich benutze gerade die neue Park App! Die ist echt super!";
					// adding message
					shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,
							shareMessage);
					// send the Intents
					TabGroupActivity parentActivity = (TabGroupActivity) getParent();
					parentActivity.startActivity(Intent.createChooser(
							shareIntent,
							"Entscheiden Sie über was Sie teilen möchten:"));

					break; 
				case 1:
					Intent QRintent = new Intent(getApplicationContext(),com.google.zxing.client.android.CaptureActivity.class);
					startActivity(QRintent); 
					break;
					
				case 2:
					Intent Quiz = new Intent(getApplicationContext(), QuizActivity.class);
					startActivity(Quiz);

					break;
				case 3:
					 Intent Wallpaper = new Intent(getParent(), WallpaperActivity.class);
					 TabGroupActivity WallpaperActivity = (TabGroupActivity)getParent();
					 WallpaperActivity.startChildActivity("Wallpaper", Wallpaper);

					break;
				case 4:
					Intent Help = new Intent(getApplicationContext(), HelpActivity.class);
					startActivity(Help);
					
					break;

				default:
					// Do Nothing!
				}

			}
		});

	}
}
